<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="../vue.js"></script>
  </head>

  <body>
    <div id="app">
      <!-- 3.组件的使用 -->
      <App />
    </div>
    <script>
      Vue.config.productionTip = false;

     const App = Vue.extend({
        template: `
          <div>
            <h1>App组件{{count}}</h1> 
            <button @click="changeCount">累加</button>
          </div>
        `,
        data() {
          return {
            count: 0,
          };
        },
        methods: {
          changeCount() {
            //组件中事件函数的this指向的是当前组件的实例对象
            console.log(this, "this");
            this.count++;
          },
        },
      });
      /* 
        Vue.extend方法返回一个VueComponent的构造函数,当这个组件被注册并使用的时候会实例化得到一个组件实例(组件实例化对象)
      */
      console.log(App, "App");

      const vm = new Vue({
        el: "#app",
        data() {
          return {};
        },
        components: {
          App,
        },
      });
    </script>
  </body>
</html>
